package com.gzx.plugin.tjzy.modular.sms.whitelist.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.sms.whitelist.bo.GzxSmsWhitelistAddOrEditBo;
import com.gzx.plugin.tjzy.modular.sms.whitelist.bo.GzxSmsWhitelistImportBo;
import com.gzx.plugin.tjzy.modular.sms.whitelist.bo.GzxSmsWhitelistQueryBo;
import com.gzx.plugin.tjzy.modular.sms.whitelist.service.GzxSmsWhitelistService;
import com.gzx.plugin.tjzy.modular.sms.whitelist.vo.GzxSmsWhitelistVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author xbl
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tjzy/whitelist")
public class GzxSmsWhitelistController {

    private final GzxSmsWhitelistService smsWhitelistService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxSmsWhitelistVo>> pageList(@RequestBody GzxSmsWhitelistQueryBo smsWhitelistQueryBo) {
        return CommonResult.data(smsWhitelistService.pageList(smsWhitelistQueryBo));
    }

    @PostMapping("/addOrEdit")
    @CommonLog("短信白名单新增")
    public CommonResult<Void> addOrEdit(@RequestBody GzxSmsWhitelistAddOrEditBo smsWhitelistAddOrEditBo) {
        smsWhitelistService.addOrEdit(smsWhitelistAddOrEditBo);
        return CommonResult.ok();
    }

    @GetMapping("/delete/{id}")
    @CommonLog("短信白名单删除")
    public CommonResult<Void> delete(@PathVariable Long id) {
        smsWhitelistService.delete(id);
        return CommonResult.ok();
    }

    @CommonLog("短信白名单导入")
    @PostMapping("/importExcel")
    public CommonResult<Void> importExcel(@RequestPart("importBo") GzxSmsWhitelistImportBo importBo, @RequestPart("multipartFile") MultipartFile multipartFile) {
        smsWhitelistService.importExcel(importBo, multipartFile);
        return CommonResult.ok();
    }
}
